const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        'msg/msg': './src/msg/msg.js',
        'info/info': './src/info/info.js'
    },
    module: {
        rules: [{
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.scss$/,
                use: [
                    'style-loader',
                    'css-loader',
                    'sass-loader'
                ]
            },
            {
                test: require.resolve('jquery'),
                use: [{
                    loader: 'expose-loader',
                    options: '$'
                }]
            },
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        extensions: [".tsx", ".ts", ".js"]
    },
    plugins: [
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin({
            filename: 'msg/msg.html',
            template: './src/msg/msg.html',
            inject: true,
            title: 'msg',
            author: 'msg-author',
            chunks: ['msg/msg'],
            date: new Date()
        }),
        new HtmlWebpackPlugin({
            filename: 'info/info.html',
            template: './src/info/info.html',
            inject: true,
            title: 'info',
            author: 'info-author',
            chunks: ['info/info'],
            date: new Date()
        })
    ],
    output: {
        filename: '[name].bundle.js',
        chunkFilename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist')
    }
};